package de.schule.barnimgymnasium.autotransporter;

import java.util.ArrayList;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Programm {

	private final int ANZAHL_TRANSPORTER = 1;
	Shell mainWindow;
	ArrayList<ButtonLine> buttonlines = new ArrayList<ButtonLine>(
			ANZAHL_TRANSPORTER);

	public Programm() {
		this.mainWindow = new Shell(SWT.CLOSE | SWT.TITLE);
		this.mainWindow.setText("Albernes Kinderspielzeug");
		mainWindow.setLayout(new RowLayout(SWT.VERTICAL));
		GameArea gameArea = new GameArea(mainWindow, ANZAHL_TRANSPORTER);

		for (int i = 1; i <= ANZAHL_TRANSPORTER; i++) {
			ButtonLine b = new ButtonLine(mainWindow, i);
			buttonlines.add(b);
			b.setSpielEventListener(gameArea.getSpielEventListener(i));
		}
	}

	public static void main(final String arg[]) {
		final Programm prog = new Programm();
		prog.run();
	}

	private void run() {
		mainWindow.pack();
		this.mainWindow.open();
		final Display display = this.mainWindow.getDisplay();
		while (!this.mainWindow.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
}
